namespace Xmef.Engine.Internal
{
    using System;
    using System.Collections.Generic;
    using Xmef.Engine;
    using Xmef.Interfaces;

    [Serializable]
    internal class PluginAttributes : IPluginAttributes
    {
        private List<IPlugin> _attributes;
        private readonly string _author;
        private readonly string _description;
        private readonly string _name;
        private readonly string _type;

        public PluginAttributes(System.Type type, IEnumerable<IPlugin> attributes)
        {
            this._attributes = new List<IPlugin>(attributes);
            IPlugin nameAttribute = this._attributes.Find(delegate (IPlugin attribute) {
                return attribute.GetType().GUID == typeof(PluginNameAttribute).GUID;
            });
            IPlugin authorAttribute = this._attributes.Find(delegate (IPlugin attribute) {
                return attribute.GetType().GUID == typeof(PluginAuthorAttribute).GUID;
            });
            IPlugin descriptionAttribute = this._attributes.Find(delegate (IPlugin attribute) {
                return attribute.GetType().GUID == typeof(PluginDescriptionAttribute).GUID;
            });
            IPlugin typeAttribute = this._attributes.Find(delegate (IPlugin attribute) {
                return attribute.GetType().GUID == typeof(PluginTypeAttribute).GUID;
            });
            if (nameAttribute != null)
            {
                this._name = nameAttribute.Value;
            }
            if (authorAttribute != null)
            {
                this._author = authorAttribute.Value;
            }
            if (descriptionAttribute != null)
            {
                this._description = descriptionAttribute.Value;
            }
            if (typeAttribute != null)
            {
                this._type = typeAttribute.Value;
            }
        }

        public IPlugin GetAttribute(System.Type type)
        {
            return this._attributes.Find(delegate (IPlugin attribute) {
                return attribute.GetType().GUID == type.GUID;
            });
        }

        public string Author
        {
            get
            {
                return this._author;
            }
        }

        public string Description
        {
            get
            {
                return this._description;
            }
        }

        public string Name
        {
            get
            {
                return this._name;
            }
        }

        public string Type
        {
            get
            {
                return this._type;
            }
        }
    }
}

